package com.itheima_01;

public class ArrayDemo2 {
    public static void main(String[] args){
        //获取最值
        int[] arr = {15, 18, 35, 12, 10, 33};
        int max = arr[0];
        int min = arr[0];
        for(int i = 1; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        System.out.println("数组中的最大值：" + max);
        for(int j = 1; j < arr.length; j++) {
            if (min > arr[j]) {
                min = arr[j];
            }
        }
        System.out.println("数组中的最小值：" + min);

        //静态初始化
       /* int[] arr = {1, 2, 3};
        System.out.println(arr);
        System.out.println(arr[0]);
        System.out.println(arr[1]);
        System.out.println(arr[2]);
        System.out.println("-----");*/

        //遍历
       /* for(int i = 0; i < arr.length; i++){
            System.out.println(arr[i]);
        }*/

        //索引越界:ArrayIndexOutOfBoundsException
        //System.out.println(arr[3]);

        //空指针异常：NullPointerException
       // arr = null;
        //System.out.println(arr[0]);
    }
}
